<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
 const someAsyncThing = function() {
    return new Promise(function(resolve, reject) {
      // 下面一行会报错，因为x没有声明
      // resolve(x + 2);
      resolve(2)
    });
  };

  someAsyncThing().then(function() {
    console.log('everything is great');
    
    return Promise.reject({
      notRealPromiseException: true
    })
  }).then(() => {
    console.log('haha')
  }, (e) => {
    console.log(e)
  }).finally(() => {
    console.log('finally')
  })

  setTimeout(() => { console.log(123) }, 2000);

  </script>
</body>
</html>